<@compress single_line=false>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="Bookmark" href="favicon.ico" >
    <link rel="Shortcut Icon" href="favicon.ico" />
    <link rel="stylesheet" type="text/css" href="/lib/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="/lib/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="/lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="/lib/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="/lib/h-ui.admin/css/style.css" />
    <title>H-ui.admin v3.0</title>
    ${css!}
</head>
<body>
<@content/>
<script type="text/javascript" src="/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="/lib/jquery.form/4.3.0/jquery.form.min.js"></script>
<script type="text/javascript" src="/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="/lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="/lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript" src="/lib/h-ui/js/H-ui.js"></script>
<script type="text/javascript">
    var CURRENT_PATH = window.location.pathname.split('?')[0];
    var JC = JC || {};

    /*判断变量是否为空*/
    JC.empty = function(v){
        switch (typeof v){
            case 'undefined' : return true;
            case 'string' : if($.trim(v).length == 0) return true; break;
            case 'boolean' : if(!v) return true; break;
            case 'number' : if(0 === v) return true; break;
            case 'object' :
                if(null === v) return true;
                if(undefined !== v.length && v.length==0) return true;
                for(var k in v){return false;} return true;
                break;
        }
        return false;
    };

    /*左侧菜单响应式*/
    function Huiasidedisplay(){
        if($(window).width()>=768){
            $(".Hui-aside").show()
        }
    }
    /*获取皮肤cookie*/
    function getskincookie(){
        let v = $.cookie("Huiskin");
        var hrefStr=$("#skin").attr("href");
        if(v==null||v==""){
            v="default";
        }
        if(hrefStr!=undefined){
            let hrefRes=hrefStr.substring(0,hrefStr.lastIndexOf('skin/'))+'skin/'+v+'/skin.css';
            $("#skin").attr("href",hrefRes);
        }
    }
    /*layer弹出层*/
    /**
     * 弹出层
     * @param title 标题
     * @param url  请求的地址
     * @param w 弹出层宽
     * @param h 弹出层高
     */
    function openLayer(title,url,w,h){
        openLayer(title,url,w,h,false);
    }

    /**
     * 弹出层
     * @param title 标题
     * @param url  请求的地址
     * @param w 弹出层宽
     * @param h 弹出层高
     * @param f 是否全屏,默认flse,true:全屏;false:非全屏
     * @param xn 最大化最小化，默认false
     */
    function openLayer(title,url,w,h,f,xn){
        if(JC.empty(title)){
            title=false; /*false：隐藏标题栏*/
        }
        if(JC.empty(url)){
            url="/error/404.html";
        }
        if(JC.empty(w)){
            w=800;
        }
        if(JC.empty(h)){
            h=($(window).height() - 50);
        };
        if(JC.empty(f)){
            f = false;
        }
        if(JC.empty(xn)){
            xn = false;
        }
        let index = layer.open({
            type: 2,
            area: [w+'px', h +'px'],
            fix: false, //不固定
            maxmin: xn,
            shade:0.4,
            title: title,
            content: url
        });
        if(f){
            layer.full(index);
        }

    }

    /**
     * 关闭弹出层
     */
    function closeLayer(){
        let index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    }

    /* AJAX请求默认选项，处理连接超时问题 */
    $.ajaxSetup({
        timeout: 10000,
        beforeSend: function () {
            layer.load(0);
        },
        complete: function (xhr,status) {
            layer.closeAll('loading');
            if (xhr.status == 401) {
                layer.confirm('session连接超时，是否重新登录？', {
                    btn: ['是', '否']
                }, function () {
                    window.top.location = '/login';
                });
            }
            if (xhr.status == 403){
                layer.msg('您没有此操作的权限');
            }
            if (xhr.status >= 500){
                layer.alert('系统异常，请联系管理员处理');
            }
            let ret = $.parseJSON(xhr.responseText);
            if (ret.errno == 400){
                layer.alert('请求参数异常 : <br/>'+ret.msg.replace(',','<br/>'))
            }
            if (ret.errno == 500){
                layer.alert(ret.msg)
            }
        }
    });

    $(function(){
        getskincookie();
        Huiasidedisplay();
        let resizeID;
        $(window).resize(function(){
            clearTimeout(resizeID);
            resizeID = setTimeout(function(){
                Huiasidedisplay();
            },500);
        });

        $(".nav-toggle").click(function(){
            $(".Hui-aside").slideToggle();
        });
        $(".Hui-aside").on("click",".menu_dropdown dd li a",function(){
            if($(window).width()<768){
                $(".Hui-aside").slideToggle();
            }
        });

        /*左侧菜单*/
        $(".Hui-aside").Huifold({
            titCell:'.menu_dropdown dl dt',
            mainCell:'.menu_dropdown dl dd',
        });

        /*换肤*/
        $("#Hui-skin .dropDown-menu a").click(function(){
            let v = $(this).attr("data-val");
            $.cookie("Huiskin", v);
            let hrefStr=$("#skin").attr("href");
            let hrefRes=hrefStr.substring(0,hrefStr.lastIndexOf('skin/'))+'skin/'+v+'/skin.css';
            $(window.frames.document).contents().find("#skin").attr("href",hrefRes);
        });

        /** 所有含class：openLayer 的按钮，点击触发弹层 */
        $(".openLayer").on('click',function (e) {
            let title = $(this).data('title');
            let url = $(this).data('url');
            let width = $(this).data('width');
            let height = $(this).data('height');
            let full = $(this).data('full');
            let xn = $(this).data('xn');
            openLayer(title,url,width,height,full,xn);
        });
        /** 所有含class：openDialog 的按钮，点击触发对话框 */
        $(".openDialog").on('click',function (e) {
            let icon = $(this).data('icon');/*弹框图标*/
            if(JC.empty(icon)){
                icon = 3;/*默认信息符号，1：ok；2：error；3：ask；4：lock*/
            }
            let title = $(this).data('title');/*弹框标题*/
            if(JC.empty(title)){
                title = '提示';
            }
            let content = $(this).data('content');/*弹框内容*/
            if(JC.empty(content)){
                content = '确定要继续吗？';
            }
            let url = $(this).data('url');/*弹框确认后操作链接*/
            if(JC.empty(url)){
                url="/error/404.html";
            }
            layer.confirm(content, {icon: icon, title:title}, function(index){
                $.ajax({
                    url:url,
                    type:'post',
                    data:{},
                    dataType:'json',
                    success:function (json) {
                        layer.close(index);
                        if(json.errno==0){
                            layer.msg('操作成功', {icon: 1,time:1000}, function(){
                                window.top.location.reload();
                            });
                        }else{
                            layer.msg(json.msg);
                        }
                    }
                });
            });
        });

        /* 提交表单数据 */
        $(document).on("click", ".form-submit", function (e) {
            e.preventDefault();
            let form = $(this).parents("form");
            let url = form.prop("action");
            let serializeArray = form.serializeArray();
            $.post(url, serializeArray, function (result) {
                if(result.errno == 0){
                    window.top.location.reload();
                }
            },'json');
        });


        /**菜单自动选中*/
        let liElements = $(".Hui-aside").find("div.menu_dropdown").find("ul").children("li");
        if(liElements && liElements.length > 0){
            liElements.each(function (idx) {
                $LI=$(this);
                if($LI.children("a").attr("href")==CURRENT_PATH){
                    $LI.addClass("current");
                    $LI.parents("dd").css("display","block");
                    $LI.parents("dd").siblings("dt").addClass("selected");
                }
            });
        }
        if(!liElements.parents("dd").siblings("dt").hasClass("selected")){
            liElements.each(function (idx) {
                $LI=$(this);
                if($LI.hasClass('current')){
                    return ;
                }
                let uri=$LI.children("a").attr("href");
                let baseUrl=uri.substring(0,uri.lastIndexOf('/')+1)
                if(CURRENT_PATH.indexOf(baseUrl)>-1){
                    $LI.addClass("current");
                    $LI.parents("dd").css("display","block");
                    $LI.parents("dd").siblings("dt").addClass("selected");
                }
            });
        }
    });

</script>
${js!}
</body>
</html>
</@compress>